package com.siwei.infoextract.rule;

import com.siwei.infoextract.wrapper.parser.DomNode;

public class Criteria {
	public static final String CRITERIA_NAME_ISORGANIZATION = "isOrganizationPattern";
	public static final String CRITERIA_NAME_ISPHONE = "isPhonePattern";
	public static final String CRITERIA_NAME_ISADDRESS = "isAddressPattern";
	public static final String CRITERIA_NAME_TAGNAME = "tagName";

	String criteriaName;
	String criteriaValue;

	public static Criteria createCriteria(String name, String value) {
		if (CRITERIA_NAME_ISORGANIZATION.equals(name.trim())) {
			return new IsOrganizationPatternCriteria(name, value);
		} else if (CRITERIA_NAME_ISPHONE.equals(name.trim())) {
			return new IsPhonePatternCriteria(name, value);
		} else if (CRITERIA_NAME_ISADDRESS.equals(name.trim())) {
			return new IsAddressPatternCriteria(name, value);
		} else if (CRITERIA_NAME_TAGNAME.equals(name.trim())) {
			return new TagNameCriteria(name, value);
		} else {
			throw new IllegalArgumentException("Criteria doesn't support yet:" + name);
		}
	}

	Criteria(String criteriaName, String criteriaValue) {
		this.criteriaName = criteriaName;
		this.criteriaValue = criteriaValue;
	}
	
	public boolean doAction(DomNode domNode) {
		// do nothing in the super class
		return false;
	}

}
